<?php
function reequipment_adminapi_updatemodels($args)
{
    // Get arguments from argument array
    extract($args);

    // Get datbase setup
    $dbconn =& xarDBGetConn();
    $xartable =& xarDBGetTables();
    $table = $xartable['remodels'];

    $update = array();
    $bindvars = array();

    // Update item
    $query = "UPDATE $table SET ";
    if (isset($model_id)){
        $update[] = "model_id = ? ";
        $bindvars[] = $model_id;
    }
    if (isset($area_id)){
        $update[] = "area_id = ? ";
        $bindvars[] = $area_id;
    }
    if (isset($model_name)){
        $update[] = "model_name = ? ";
        $bindvars[] = $model_name;
    }
    if (isset($current)){
        $update[] = "current = ? ";
        $bindvars[] = $current;
    }
    $query .= join(",",$update);
    $query .= "WHERE model_id = ? ";
    $bindvars[] = $model_id;
    $result =& $dbconn->Execute($query, $bindvars);
    if (!$result) return;
    // Let any hooks know that we have created a new topic
    $args['module'] = 'reequipment';
    $args['itemtype'] = 2; //tag
    $args['itemid'] = $model_id;
    xarModCallHooks('item', 'update', $model_id, $args);
    // Return the id of the newly created link to the calling process
    return true;
}
?>